<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基本语法</title>
</head>
<body>
<script>
    //实例化Promise对象
    const p = new Promise(function (resolve, reject) {
        setTimeout(function () {
            let data='I Love You ~';
            resolve(data);//读取成功调用的一个回调
            let err='data err !'
            reject(err)//读取失败调用第二个回调
        });
    });
    //调用Promise对象中的then方法
    p.then(function (value) {
        console.log(value)
    },function (reason) {
        console.log(reason)
    })
</script>
</body>
</html>